import Banner from "../Banner";
import { PlayerData } from "../Datas/Data";
import { Constant, ItemType } from "../Framework/Const/Constant";
import AudioManager from "../Framework/Managers/AudioManager";
import { DataManager } from "../Framework/Managers/DataManager";
import { UIManager } from "../Framework/Managers/UIManager";
import NodeUtil from "../Framework/Utils/NodeUtil";
const { ccclass, property } = cc._decorator;

@ccclass
export default class WinPanel extends cc.Component {

    BlackMask: cc.Node = null;

    protected onLoad(): void {
        this.BlackMask = NodeUtil.GetNode("BlackMask", this.node);
    }

    Show() {
        if (Banner.NeedShowMoreAd) {
            Banner.Instance.ShowVideoAd(() => { });
        }

        Banner.Instance.ShowCustomAd();

        DataManager.EXP += 1000;
        cc.Tween.stopAllByTarget(this.BlackMask);
        this.BlackMask.opacity = 255;
        cc.tween(this.BlackMask).to(1, { opacity: 0 }).start();

        UIManager.Instance.ShowPanel(Constant.Panel.TreasureBox);
    }

    OnButtonClick(event: cc.Event) {
        AudioManager.PlayAudio(Constant.Audio.ButtonClick);
        switch (event.target.name) {
            case "EndButton":
                UIManager.Instance.ShowPanel(Constant.Panel.LoadingPanel, [`Start`]);
                break;
        }
    }
}
